/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function(nums, target) {
    var i = 0, j = 0, length = nums.length;
    for(i=0;i<length;i++){
        for(j=length-1;j>=i;j--){
            if(i === j)break;
            if(nums[i]+nums[j] == target){
                return [i, j];
            }
        }
    }

    return [];

};


console.log(twoSum([1,7,9],8));